home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT8 / PG0800.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  4.5 KB  |  103 lines

  1. ;***********************************************************************
  2. ;
  3. ;  Program PG0800 ( Chapter 8 )
  4. ;
  5. ;  Output 24 lines of text onto the screen
  6. ;
  7. ;  Author: A.I.Sopin, VSU, Voronezh, 1992
  8. ;
  9. ;  The BIOS video service (interrupt 10h) is used
  10. ;
  11. ;***********************************************************************
  12. .model  small
  13.  
  14. EXTRN   VIDTYP : FAR
  15.  
  16. LF      EQU     10      ;  Line Feed
  17. CR      EQU     13      ;  Carriage Return
  18.  
  19. ;----------------------------------------------------------
  20. .stack
  21. .data
  22. STRING  DB      80 dup ('E'), 0
  23. Nstr    DB      24
  24. TEXT0   DB      ' Output to Screen (BIOS  INT  10h).  Press any key...'
  25.     DB      CR, LF, '$'
  26. TEXT1   DB      ' Video Type = '
  27. VTypeS  DB      'X'
  28.     DB      '   MODE = '
  29. VModeS  DB      'X'
  30.     DB      '    Press any key...$'
  31. MODE    DB      0
  32. VMODE   DB      0               ; original video mode saved
  33. ;----------------------------------------------------------
  34. .code
  35. .startup
  36.     mov     ah,0Fh                  ;  function 0Fh - get video mode
  37.     int     10h                     ;  BIOS video service call
  38.     mov     VMODE,al                ;  save original video mode
  39.     mov     ah,0                    ;  function 00h - set video mode
  40.     mov     al,2                    ;  video mode 2 - 80x25  B & W
  41.     int     10h                     ;  BIOS video service call
  42.     mov     ah,2                    ;  function 02h - set cursor
  43.     xor     dx,dx                   ;  cursor position 0, 0
  44.     xor     bh,bh                   ;  video page 0 is used
  45.     int     10h                     ;  BIOS video service call
  46.     lea     dx,TEXT0                ;  address of text to be output
  47.     mov     ah,9                    ;  function 09h - output text string
  48.     int     21h                     ;  DOS service call
  49.     xor     ah,ah                   ;  function 00h - get key
  50.     int     16h                     ;  BIOS keyboard service call
  51. ;  determine and report the video adapter type and video mode
  52.     Call    VIDTYP                  ;
  53.     mov     VTypeS,al               ;  Video Adapter Type
  54.     or      VTypeS,30h              ;  Bin ---> ASCII
  55.     mov     ah,0Fh                  ;  function 0Fh - get video mode
  56.     int     10h                     ;  BIOS video service call
  57.     mov     VModeS,al               ;  Video Mode
  58.     or      VModeS,30h              ;  Bin ---> ASCII
  59.     lea     dx,TEXT1                ;  address of text to be output
  60.     mov     ah,9                    ;  function 09h - output text string
  61.     int     21h                     ;  DOS service call
  62.     xor     ah,ah                   ;  function 00h - get key
  63.     int     16h                     ;  BIOS keyboard service call
  64.     mov     ah,2                    ;  function 02h - set cursor
  65.     xor     dx,dx                   ;  cursor position 0, 0
  66.     xor     bh,bh                   ;  video page 0 is used
  67.     int     10h                     ;  BIOS video service call
  68. ;-------------------------------------------------------------------
  69. ;  Output  ASCIIZ  string onto the screen
  70.     mov     Nstr,24                 ;  number of lines to be output
  71. M0:     lea     si,STRING               ;
  72.     Call    PUTSTR                  ;
  73.     dec     Nstr                    ;
  74.     jnz     M0                      ;
  75.     mov     ah,0                    ;  function 00h - get key
  76.     int     16h                     ;  BIOS keyboard service call
  77. ;-------------------------------------------------------------------
  78. ;  Finish the program and return to MS-DOS
  79. Exit:   mov     al,VMODE                ;  AL - original video mode
  80.     xor     ah,ah                   ;  function 00h - set video mode
  81.     int     10h                     ;  BIOS video service call
  82.     mov     ax,4C00h                ;  Return Code =0
  83.     int     21h                     ;  BIOS video service call
  84. ;-------------------------------------------------------------------
  85. ;
  86. ;  Output ASCIIZ - string (80  characters) onto the screen
  87. ;
  88. ;  DS:SI  - start address of a string to be outpit
  89. ;
  90. ;-------------------------------------------------------------------
  91. PUTSTR  PROC   NEAR
  92. Cycle:  lodsb                           ;  next character into  AL
  93.     and     al,al                   ;  EOL (NULL character) ?
  94.     jz      EOPUT                   ;  if NULL, stop output and return 
  95.     xor     bx,bx                   ;  video page 0 is used
  96.     mov     ah,0Eh                  ;  function 0Eh - teletype output
  97.     int     10h                     ;  BIOS video service call
  98.     jmp     short Cycle             ;  to next character
  99. EOPUT:  RETN                            ;  return to caller
  100. PUTSTR  ENDP
  101. ;-------------------------------------------------------------------
  102.     END
  103.